<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="support.*, java.util.*, myclasses.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Country of citizenship</title>
</head>
<body>
<%
	/*creating a data structure to hold the students*/
	/* NOT SURE WHERE WE ARE SUPPOSED TO HAVE THE HM.
		NEW STUDENT FOR EVERY SESSION...
	LinkedHashMap<String, Student> hm = new LinkedHashMap<String, Student>();
	session.setAttribute("hashmap",hm);*/

	String firstName = request.getParameter("firstName");
	/*session.setAttribute("firstName", firstName);*/
	String middleInitial = request.getParameter("middleInitial");
	/*session.setAttribute("middleInitial", middleInitial);*/
	String lastName = request.getParameter("lastName");
	/*session.setAttribute("lastName", lastName);*/
	
	/*NOTE: NOW WE HAVE TO CHANGE HOW WE GET THE ATTRIBUTES
	  IN FUTURE .jsp CODE!!!*/
	  
	/*btw: what is best have the student object in the session until
	  all information is collected, then put the student in the hashmap?
	  	-try collecting all info first.*/
	
	Student stud = new Student(firstName, middleInitial, lastName);
	session.setAttribute("student", stud);
%>
	
<center>
Welcome <%= firstName %> <%= middleInitial %>. <%= lastName %>.<br>
Please choose your country of citizenship:
</center>

<% 	String path1 = config.getServletContext().getRealPath("countries.txt");
	support s = new support();
	Vector countries = s.getCountries(path1);
	
	Integer columncounter = 0;
	out.println("<br>");
	out.println("<table width=\"600\" border=\"2\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\">");
	for(int i=0; i<countries.size(); i++) {
		columncounter += 1;
		if(columncounter == 1)
			out.println("<tr>");
		
		out.println("<td>" + "<a href=\"http://localhost:8080/GraduateSchoolApp/residence.jsp?citizenship=" + countries.get(i) + "\">" + countries.get(i) + "</a>" + "</td>");
		
		if (columncounter >= 3) {
			out.println("</tr>");
			columncounter = 0;
		}
	}

	out.println("</table>");
	out.println("<br>"); %>

</body>
</html>